Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
find the character "(" in a string in js

I have a string in my JS that may contain the character (M and I need to find their position - but I can't work out how to without throwing an error I guess due to the bracket.

const findMTag = "(M"; //I need to search for this but it throws an error
let posMTag = nameJoined.search(findMTag);
console.log("TAG position =  " + posMTag);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try with indexOf

const findMTag = "(M"; //I need to search for this but it throws an error
let posMTag = nameJoined.indexOf(findMTag);
console.log("TAG position =  " + posMTag);
about 4 years ago · Juan Pablo Isaza Denunciar

0

String.search accepts a Regular expression as its argument, but you're passing a string to it, so it doesn't work. Take a look at String.search() for more info.

So your code will look like:

const findMTag = /\(M/;
const posMTag = nameJoined.search(findMTag);
console.log("TAG position =  " + posMTag);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda